<template>
  <div class="home">
    <H1>你好{{ $store.state.userName }}</H1>
    <div>
      <button @click="setUserName">更新全局姓名</button>
    </div>
    <img alt="Vue logo" src="../assets/logo.png" />
    <HelloWorld msg="Welcome to Your Vue.js App" />
  </div>
</template>

<script>
// @ is an alias to /src
import HelloWorld from "@/components/HelloWorld.vue";

export default {
  name: "HomeView",
  components: {
    HelloWorld,
  },
  methods: {
    setUserName() {
      this.$store.dispatch("setUserName", "新名称" + new Date() * 1);
    },
  },
};
</script>
